import { getAction, postAction } from '@/api/manage'
import { PAGE_MENU_TYPE } from '@/store/mutation-types'

export const EvalutionMixin = {
  components: {},
  data() {
    return {
      loading: true,
      saveLoading: false
    }
  },

  methods: {
    //获取首页
    getEvalutionList() {
      let params = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }
      var url = 'evaluation/list'
      getAction(url, params)
        .then(res => {
          if (res.success) {
            console.log('getEvalutionList:', res)
            this.data = []
            for (let i = 0; i < res.result.length; i++) {
              if (res.result[i].path !== null) {
                this.data.push({
                  name: res.result[i].evaluationName,
                  introduction: res.result[i].intro ? res.result[i].intro : '暂缺',
                  time: res.result[i].quizTime ? res.result[i].quizTime + '分钟' : '-',
                  wrote: res.result[i].count ? res.result[i].count : '0',
                  url: res.result[i].path
                })
              }
            }
            this.data = this.data.map((item, index) => {
              return { ...item, index: index + 1 }
            })
          }
          if (res.code === 500) {
            this.error1()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },

    //获取Parq量表
    getParq() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getParq, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,

                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeParq()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Parq预览记录
    changeParq() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.radios.radio1 = this.savaRes[key].answers[0]
      this.radios.radio2 = this.savaRes[key].answers[1]
      this.radios.radio3 = this.savaRes[key].answers[2]
      this.radios.radio4 = this.savaRes[key].answers[3]
      this.radios.radio5 = this.savaRes[key].answers[4]
      this.radios.radio6 = this.savaRes[key].answers[5]
      this.radios.radio7 = this.savaRes[key].answers[6]
    },

    //保存Parq量表
    postParq() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      // this.saveLoading = true
      var params = { patientId: this.queryParam.patientId, answers: inputs }
      postAction(this.url.postParq, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.panes = []
            this.success()
            this.getParq()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },

    //获取Parq量表
    getNrs() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getNrs, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createDate,

                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeNrs()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Parq预览记录
    changeNrs() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.model.diseaseStatus = this.savaRes[key].diseaseStatus
      this.model.isSeventy = this.savaRes[key].isSeventy
      this.model.nutritionalStatus = this.savaRes[key].nutritionalStatus
    },

    //保存Nrs量表
    postNrs() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      // this.saveLoading = true
      var params = {
        patientId: this.queryParam.patientId,
        diseaseStatus: this.model.diseaseStatus,
        isSeventy: this.model.isSeventy,
        nutritionalStatus: this.model.nutritionalStatus
      }
      postAction(this.url.postNrs, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.panes = []
            this.success()
            this.getNrs()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },

    //获取Sdsca量表
    getSdsca() {
      let queryParam = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }
      getAction(this.url.getSdsca, queryParam)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,
                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeSdsca()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Sdsca预览记录
    changeSdsca() {
      //先将量表所有选项清空，接口有数据的分页会将存在savaRes里面的数据渲染上去，新增的填写页将不会执行获取saveRes数据的步骤
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.radios.radio1 = this.savaRes[key].answers[0]
      this.radios.radio2 = this.savaRes[key].answers[1]
      this.radios.radio3 = this.savaRes[key].answers[2]
      this.radios.radio4 = this.savaRes[key].answers[3]
      this.radios.radio5 = this.savaRes[key].answers[4]
      this.radios.radio6 = this.savaRes[key].answers[5]
      this.radios.radio7 = this.savaRes[key].answers[6]
      this.radios.radio8 = this.savaRes[key].answers[7]
      this.radios.radio9 = this.savaRes[key].answers[8]
      this.radios.radio10 = this.savaRes[key].answers[9]
      this.radios.radio11 = this.savaRes[key].answers[10]
      this.radios.radio12 = this.savaRes[key].answers[11]
    },
    //保存Sdsca量表
    postSdsca() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      this.saveLoading = true
      console.log(inputs)
      var params = { patientId: this.queryParam.patientId, answers: inputs }
      postAction(this.url.postSdsca, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //刷新当前页面
    routeReload() {
      this.reloadFlag = false
      var ToggleMultipage = 'ToggleMultipage'
      this.$store.dispatch(ToggleMultipage, false)
      this.$nextTick(() => {
        this.$store.dispatch(ToggleMultipage, true)
        this.reloadFlag = true
      })
    },

    //获取Mmas8量表
    getMmas8() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getMmas8, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,
                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeMmas8()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Mmas8预览记录
    changeMmas8() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.radios.radio1 = this.savaRes[key].answers[0]
      this.radios.radio2 = this.savaRes[key].answers[1]
      this.radios.radio3 = this.savaRes[key].answers[2]
      this.radios.radio4 = this.savaRes[key].answers[3]
      this.radios.radio5 = this.savaRes[key].answers[4]
      this.radios.radio6 = this.savaRes[key].answers[5]
      this.radios.radio7 = this.savaRes[key].answers[6]
      this.radios.radio8 = this.savaRes[key].answers[7]
    },
    //保存Mmas8量表
    postMmas8() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      this.saveLoading = true
      console.log(inputs)
      var params = { patientId: this.queryParam.patientId, answers: inputs }
      postAction(this.url.postMmas8, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //获取Bmq量表
    getBmq() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getBmq, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,
                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeBmq()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Bmq预览记录
    changeBmq() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.radios.radio1 = this.savaRes[key].answers[0]
      this.radios.radio2 = this.savaRes[key].answers[1]
      this.radios.radio3 = this.savaRes[key].answers[2]
      this.radios.radio4 = this.savaRes[key].answers[3]
      this.radios.radio5 = this.savaRes[key].answers[4]
      this.radios.radio6 = this.savaRes[key].answers[5]
      this.radios.radio7 = this.savaRes[key].answers[6]
      this.radios.radio8 = this.savaRes[key].answers[7]
      this.radios.radio9 = this.savaRes[key].answers[8]
      this.radios.radio10 = this.savaRes[key].answers[9]
    },
    //保存Bmq量表
    postBmq() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      console.log(inputs)
      this.saveLoading = true
      var params = { patientId: this.queryParam.patientId, answers: inputs }
      postAction(this.url.postBmq, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //获取Sas量表
    getSas() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getSas, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,

                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeSas()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Sas预览记录
    changeSas() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.radios.radio1 = this.savaRes[key].answers[0]
      this.radios.radio2 = this.savaRes[key].answers[1]
      this.radios.radio3 = this.savaRes[key].answers[2]
      this.radios.radio4 = this.savaRes[key].answers[3]
      this.radios.radio5 = this.savaRes[key].answers[4]
      this.radios.radio6 = this.savaRes[key].answers[5]
      this.radios.radio7 = this.savaRes[key].answers[6]
      this.radios.radio8 = this.savaRes[key].answers[7]
      this.radios.radio9 = this.savaRes[key].answers[8]
      this.radios.radio10 = this.savaRes[key].answers[9]
      this.radios.radio11 = this.savaRes[key].answers[10]
      this.radios.radio12 = this.savaRes[key].answers[11]
      this.radios.radio13 = this.savaRes[key].answers[12]
      this.radios.radio14 = this.savaRes[key].answers[13]
      this.radios.radio15 = this.savaRes[key].answers[14]
      this.radios.radio16 = this.savaRes[key].answers[15]
      this.radios.radio17 = this.savaRes[key].answers[16]
      this.radios.radio18 = this.savaRes[key].answers[17]
      this.radios.radio19 = this.savaRes[key].answers[18]
      this.radios.radio20 = this.savaRes[key].answers[19]
    },

    //保存Sas量表
    postSas() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      console.log(inputs)
      this.saveLoading = true
      var params = { patientId: this.queryParam.patientId, answers: inputs }
      postAction(this.url.postSas, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //获取Sds量表
    getSds() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getSds, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,
                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeSds()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Sds预览记录
    changeSds() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.radios.radio1 = this.savaRes[key].answers[0]
      this.radios.radio2 = this.savaRes[key].answers[1]
      this.radios.radio3 = this.savaRes[key].answers[2]
      this.radios.radio4 = this.savaRes[key].answers[3]
      this.radios.radio5 = this.savaRes[key].answers[4]
      this.radios.radio6 = this.savaRes[key].answers[5]
      this.radios.radio7 = this.savaRes[key].answers[6]
      this.radios.radio8 = this.savaRes[key].answers[7]
      this.radios.radio9 = this.savaRes[key].answers[8]
      this.radios.radio10 = this.savaRes[key].answers[9]
      this.radios.radio11 = this.savaRes[key].answers[10]
      this.radios.radio12 = this.savaRes[key].answers[11]
      this.radios.radio13 = this.savaRes[key].answers[12]
      this.radios.radio14 = this.savaRes[key].answers[13]
      this.radios.radio15 = this.savaRes[key].answers[14]
      this.radios.radio16 = this.savaRes[key].answers[15]
      this.radios.radio17 = this.savaRes[key].answers[16]
      this.radios.radio18 = this.savaRes[key].answers[17]
      this.radios.radio19 = this.savaRes[key].answers[18]
      this.radios.radio20 = this.savaRes[key].answers[19]
    },
    //保存Sds量表
    postSds() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      console.log(inputs)
      this.saveLoading = true
      var params = { patientId: this.queryParam.patientId, answers: inputs }
      postAction(this.url.postSds, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //获取Angiocardiopathy量表
    getAngiocardiopathy() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getAngiocardiopathy, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,
                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeAngiocardiopathy()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Angiocardiopathy预览记录
    changeAngiocardiopathy() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.radios.radio1 = this.savaRes[key].input && this.savaRes[key].input[0] ? this.savaRes[key].input[0] : 1
      this.radios.radio2 = this.savaRes[key].input && this.savaRes[key].input[1] ? this.savaRes[key].input[1] : 0
      this.radios.radio3 = this.savaRes[key].input && this.savaRes[key].input[2] ? this.savaRes[key].input[2] : 0
      this.radios.radio4 = this.savaRes[key].input && this.savaRes[key].input[3] ? this.savaRes[key].input[3] : 0
      this.radios.radio5 = this.savaRes[key].input && this.savaRes[key].input[4] ? this.savaRes[key].input[4] : 0
      this.radios.radio6 = this.savaRes[key].input && this.savaRes[key].input[5] ? this.savaRes[key].input[5] : 0
      this.radios.radio7 = this.savaRes[key].input && this.savaRes[key].input[6] ? this.savaRes[key].input[6] : 0
    },

    //保存Angiocardiopathy量表
    postAngiocardiopathy() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      var params = {
        patientId: this.queryParam.patientId,
        input: inputs
      }
      this.saveLoading = true
      postAction(this.url.postAngiocardiopathy, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //获取Burnout量表
    getBurnout() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getBurnout, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,

                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeBurnout()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Burnout预览记录
    changeBurnout() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.radios.radio1 = this.savaRes[key].input[0]
      this.radios.radio2 = this.savaRes[key].input[1]
      this.radios.radio3 = this.savaRes[key].input[2]
      this.radios.radio4 = this.savaRes[key].input[3]
      this.radios.radio5 = this.savaRes[key].input[4]
      this.radios.radio6 = this.savaRes[key].input[5]
      this.radios.radio7 = this.savaRes[key].input[6]
      this.radios.radio8 = this.savaRes[key].input[7]
      this.radios.radio9 = this.savaRes[key].input[8]
      this.radios.radio10 = this.savaRes[key].input[9]
      this.radios.radio11 = this.savaRes[key].input[10]
      this.radios.radio12 = this.savaRes[key].input[11]
      this.radios.radio13 = this.savaRes[key].input[12]
      this.radios.radio14 = this.savaRes[key].input[13]
      this.radios.radio15 = this.savaRes[key].input[14]
    },

    //保存Burnout量表
    postBurnout() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      console.log(inputs)
      this.saveLoading = true
      var params = { patientId: this.queryParam.patientId, input: inputs }
      postAction(this.url.postBurnout, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //获取Diabetes量表
    getDiabetes() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getDiabetes, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,

                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeDiabetes()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Diabetes预览记录
    changeDiabetes() {
      this.evalution1.output = ''
      ;(this.gender = ''),
        (this.diabetesFamily = ''),
        (this.height = ''),
        (this.birth = ''),
        (this.pressureSystolic = ''),
        (this.waistline = ''),
        (this.weight = '')
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].output
      this.gender = this.savaRes[key].gender
      this.diabetesFamily = this.savaRes[key].diabetesFamily
      this.height = this.savaRes[key].height
      this.pressureSystolic = this.savaRes[key].pressureSystolic
      this.waistline = this.savaRes[key].waistline
      this.weight = this.savaRes[key].weight
      this.birth = this.savaRes[key].birth
    },

    //保存Diabetes量表
    postDiabetes() {
      var params = {
        patientId: this.queryParam.patientId,
        birth: this.birth,
        gender: this.gender,
        diabetesFamily: this.diabetesFamily,
        height: this.height,
        pressureSystolic: this.pressureSystolic,
        waistline: this.waistline,
        weight: this.weight
      }
      this.saveLoading = true
      postAction(this.url.postDiabetes, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //获取Psqi量表
    getPsqi() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getPsqi, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,

                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changePsqi()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Psqi预览记录
    changePsqi() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].level
      this.radios.radio1 = this.savaRes[key].input[0]
      this.radios.radio2 = this.savaRes[key].input[1]
      this.radios.radio3 = this.savaRes[key].input[2]
      this.radios.radio4 = this.savaRes[key].input[3]
      this.radios.radio5 = this.savaRes[key].input[4]
      this.radios.radio6 = this.savaRes[key].input[5]
      this.radios.radio7 = this.savaRes[key].input[6]
      this.radios.radio8 = this.savaRes[key].input[7]
      this.radios.radio9 = this.savaRes[key].input[8]
      this.radios.radio10 = this.savaRes[key].input[9]
      this.radios.radio11 = this.savaRes[key].input[10]
      this.radios.radio12 = this.savaRes[key].input[11]
      this.radios.radio13 = this.savaRes[key].input[12]
      this.radios.radio14 = this.savaRes[key].input[13]
      this.radios.radio15 = this.savaRes[key].input[14]
      this.radios.radio16 = this.savaRes[key].input[15]
      this.radios.radio17 = this.savaRes[key].input[16]
      this.radios.radio18 = this.savaRes[key].input[17]
    },

    //保存Psqi量表
    postPsqi() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      console.log(inputs)
      this.saveLoading = true
      var params = { patientId: this.queryParam.patientId, input: inputs }
      postAction(this.url.postPsqi, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //获取Happiness量表
    getHappiness() {
      let data = {
        patientId: this.$route.query[PAGE_MENU_TYPE.PatientId]
      }

      getAction(this.url.getHappiness, data)
        .then(res => {
          if (res.success) {
            for (let i = 0; i < res.result.length; i++) {
              this.panes.push({
                title: res.result[i].createTime,
                key: res.result[i].dataId,
                closable: false
              })
              this.savaRes = res.result
              console.log(this.savaRes)
            }
            this.activeKey = res.result[0] ? res.result[0].dataId : 0
            this.changeHappiness()
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
    //Happiness预览记录
    changeHappiness() {
      this.evalution1.output = ''
      this.radios = []
      let key = this.savaRes.findIndex(item => {
        return this.activeKey == item.dataId
      })
      this.evalution1.output = this.savaRes[key].level
      this.radios.radio1 = this.savaRes[key].input[0]
      this.radios.radio2 = this.savaRes[key].input[1]
      this.radios.radio3 = this.savaRes[key].input[2]
      this.radios.radio4 = this.savaRes[key].input[3]
      this.radios.radio5 = this.savaRes[key].input[4]
      this.radios.radio6 = this.savaRes[key].input[5]
      this.radios.radio7 = this.savaRes[key].input[6]
      this.radios.radio8 = this.savaRes[key].input[7]
      this.radios.radio9 = this.savaRes[key].input[8]
      this.radios.radio10 = this.savaRes[key].input[9]
      this.radios.radio11 = this.savaRes[key].input[10]
      this.radios.radio12 = this.savaRes[key].input[11]
      this.radios.radio13 = this.savaRes[key].input[12]
      this.radios.radio14 = this.savaRes[key].input[13]
      this.radios.radio15 = this.savaRes[key].input[14]
      this.radios.radio16 = this.savaRes[key].input[15]
      this.radios.radio17 = this.savaRes[key].input[16]
      this.radios.radio18 = this.savaRes[key].input[17]
      this.radios.radio19 = this.savaRes[key].input[18]
      this.radios.radio20 = this.savaRes[key].input[19]
      this.radios.radio21 = this.savaRes[key].input[20]
      this.radios.radio22 = this.savaRes[key].input[21]
      this.radios.radio23 = this.savaRes[key].input[22]
      this.radios.radio24 = this.savaRes[key].input[23]
      this.radios.radio25 = this.savaRes[key].input[24]
      this.radios.radio26 = this.savaRes[key].input[25]
      this.radios.radio27 = this.savaRes[key].input[26]
      this.radios.radio28 = this.savaRes[key].input[27]
      this.radios.radio29 = this.savaRes[key].input[28]
      this.radios.radio30 = this.savaRes[key].input[29]
      this.radios.radio31 = this.savaRes[key].input[30]
      this.radios.radio32 = this.savaRes[key].input[31]
      this.radios.radio33 = this.savaRes[key].input[32]
    },

    //保存Happiness量表
    postHappiness() {
      let inputs = []
      for (let i in this.radios) {
        inputs.push(this.radios[i])
      }
      console.log(inputs)
      this.saveLoading = true
      var params = { patientId: this.queryParam.patientId, input: inputs }
      postAction(this.url.postHappiness, params)
        .then(res => {
          if (res.success) {
            console.log('postEvalution:', res)
            this.success()
            this.routeReload()
          }
          if (res.success == false) {
            this.error()
          }
        })
        .finally(() => {
          this.saveLoading = false
        })
    },
    //成功提示
    success() {
      this.$message.success('当前记录保存成功，请点击上方当前时间查看结果')
    },
    //错误提示
    error() {
      this.$message.error('当前记录保存失败,请填写所有选项')
    },
    error1() {
      this.$message.error('量表首页获取失败')
    }
  }
}
